﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

/// <summary>
/// UploadFile 的摘要说明
/// </summary>

public class UploadFileTool
{
    private static string UPLOADDIR = ConfigurationManager.AppSettings["UploadDir"];
    public static int MAXUPLOADSIZE = Convert.ToInt32(ConfigurationManager.AppSettings["MaxUploadSize"]);
    public static int MAXIMAGESIZE = 200; //200K

    public UploadFileTool()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    public static string CreateFilePath(string rootDir)
    {
        string dateStr = DateTime.Now.ToString("yyyy-MM-dd") ;
        string fileDir = rootDir + @UPLOADDIR + dateStr;

        if (!Directory.Exists(fileDir))
        {
            Directory.CreateDirectory(fileDir + "\\");
        }

        return @UPLOADDIR + dateStr + "\\";
    }

    public static string GetUploadFileName(string suffix)
    {
        return DateTime.Now.ToString("yyyy-MM-dd") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() +
            DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + suffix;
    }

    public static void DeleteFile(string rootDir, string fullName)
    {
        File.Delete(rootDir + fullName);
    }
}

